// server.js
const http = require('http');
const server = http.createServer();
const qs = require('querystring');

server.on('request', function(req, res) {
    let params = qs.parse(req.url.slice(req.url.indexOf('?')+1));
    // 向前端写cookie
    res.writeHead(200, {
        'Linwt-Cookie': '0000000000000000000000000000000000'
    });

    req.url = req.url.slice(0,req.url.indexOf('?'))
    if(req.url === '/get'){
        res.write(JSON.stringify(params));
        console.log('get..')
    }
    if(req.url === '/post'){

    }

    res.end();
});
server.listen('8081');
console.log('Server is running at port 8081...');
